#coding=utf-8

import ctypes
import os
import bpy
import time

from multiprocessing import Pool

print('lood dll mbt')
import sys


调试 = True

if 调试 :
	os.chdir('D:/U/Project/x64/BlenderSandbox/Debug')
	sys.path.append("D:/U/Project/x64/BlenderSandbox/Debug")
	dllPath = "D:/U/Project/x64/BlenderSandbox/Debug/BlenderSandbox.dll"
else:
	os.chdir('D:/U/Project/x64/BlenderSandbox/Release')
	sys.path.append("D:/U/Project/x64/BlenderSandbox/Release")
	dllPath = "D:/U/Project/x64/BlenderSandbox/Release/BlenderSandbox.dll"

#https://izihun.com/shangyongziti-574.html

flexCAPI = ctypes.WinDLL(dllPath)

#140.82.113.4 github.com
#199.232.5.194 github.global.ssl.fastly.net

flexCAPI.f_取物体插座数据.restype = ctypes.py_object
flexCAPI.f_取物体插座节点数据.restype = ctypes.py_object
flexCAPI.f_取物体集插座节点数据.restype = ctypes.py_object


flexCAPI.f_取VectorVec3插座节点数据.restype = ctypes.py_object
flexCAPI.f_取VectorInt32插座节点数据.restype = ctypes.py_object
flexCAPI.f_取矩阵插座数据.restype = ctypes.py_object
flexCAPI.f_取插座数据.restype = ctypes.py_object
flexCAPI.f_取插座ToString序列数据.restype = ctypes.py_object




flexCAPI.f_取网格插座节点数据.restype = ctypes.py_object
flexCAPI.f_取节点数据.restype = ctypes.py_object



#---------------------- 节点树 ---------------------------
flexCAPI.f_node_是否即时更新节点.restype = ctypes.c_int32
flexCAPI.f_node_节点是否存在.restype = ctypes.c_bool


#---------------------节点更新组--------------------------
flexCAPI.f_取当前插座变更节点.restype = ctypes.py_object
flexCAPI.f_取组输入输出更新插座节点.restype = ctypes.py_object
flexCAPI.f_更新节点树_begin.restype = ctypes.py_object
flexCAPI.f_get断开输入链接节点.restype = ctypes.py_object




flexCAPI.f_取Int32插座数据.restype = ctypes.c_int32
flexCAPI.f_取Float32插座数据.restype = ctypes.c_float


flexCAPI.f_bl_插座传入数据.restype = ctypes.py_object


#----------------------- 节点数据更新 --------------------------
flexCAPI.f_node_取要内部节点数量.restype = ctypes.c_int32
flexCAPI.f_取节点输入输出插座数量.restype = ctypes.py_object



flexCAPI.f_add模型.restype = ctypes.c_int32
flexCAPI.f_add虚拟物体.restype = ctypes.c_int32


print('load dll - flexCAPI : ', flexCAPI)

#q = multiprocessing.Queue(3)
#线程 = multiprocessing(garget=f_线程载入, args=(q,))






classes = []


def register():
	for c in classes:
		bpy.utils.register_class(c)
		
	print('初始化引擎')
	flexCAPI.f_InitEngine(ctypes.c_int(0), ctypes.c_wchar_p(dllPath))

	#p = Pool(1)
	#p.apply_async(f_线程载入, (1,))
	
	


def unregister():
	#bpy.types.NODE_MT_add.append(menu_draw_node_域)
	for c in classes:
		bpy.utils.unregister_class(c)

	flexCAPI.f_CloseEngine(ctypes.c_int(0))



